import { defineStore } from 'pinia';

export const MobileUserStore = defineStore('mobileUser', () => {
  // const account = localStorage.getItem('_mobile_site_login_account');
  // const customerName = ref(localStorage.getItem('_mobile_site_login_customerName'));
  // const customerId = localStorage.getItem('_mobile_site_login_userId');
  // const token = localStorage.getItem('_mobile_site_token');
  // const reminder = localStorage.getItem('_mobile_site_reminder');
  const setUserInfo = (customer: any) => {
    localStorage.setItem('_mobile_site_login_account', customer.account);
    localStorage.setItem('_mobile_site_login_username', customer.customerName);
    localStorage.setItem('_mobile_site_login_userId', customer.customerId);
    localStorage.setItem('_mobile_site_token', customer.token);
    localStorage.setItem('_mobile_site_reminder', customer.reminder);
  };

  // 清理会员信息，退出时使用
  const clearUserInfo = () => {
    localStorage.removeItem('_mobile_site_token');
  };

  return {
    // account,
    // token,
    // reminder,
    // customerName,
    // customerId,
    setUserInfo,
    clearUserInfo,
  };
});
